<template>
	<view class="profile-container">
		<view class="profile-card">
			<view class="profile-item">
				<view class="item-label">实名认证</view>
				<view class="item-value">
					<text>{{userInfo.realName ? ('已认证('+userInfo.realName+')') : '未认证'}}</text>
					<button v-if="!userInfo.realName" class="action-btn" @click="toUserBind(1)">去认证</button>
				</view>
			</view>
			<view class="item-divider"></view>

			<view class="profile-item">
				<view class="item-label">绑定微信</view>
				<view class="item-value">
					<text>{{userInfo.weixin ? userInfo.weixin : '未绑定'}}</text>
					<button class="action-btn" @click="toUserBind(2)">{{userInfo.weixin?'重新绑定':'去绑定'}}</button>
				</view>
			</view>
			<view class="item-divider"></view>

			<view class="profile-item">
				<view class="item-label">绑定手机号</view>
				<view class="item-value">
					<text>{{userInfo.phone ? userInfo.phone : '未绑定'}}</text>
					<button class="action-btn" @click="toUserBind(3)">{{userInfo.phone?'重新绑定':'去绑定'}}</button>
				</view>
			</view>
			<view class="item-divider"></view>

			<view class="profile-item">
				<view class="item-label">个人简历</view>
				<view class="item-value">
					<button class="action-btn" @click="toEditResume">编辑简历</button>
				</view>
			</view>
			<view class="item-divider"></view>

			<view class="profile-item">
				<view class="item-label">职业认定</view>
				<view class="item-value">
					<button class="action-btn" @click="tocertVerify">去认定</button>
				</view>
			</view>
			<view class="item-divider"></view>

			<view class="profile-item">
				<view class="item-label">我的奖励({{enableNum.remainAmount}}元)</view>
				<view class="item-value">
					<button class="action-btn" @click="toWithdraw">去提现</button>
				</view>
			</view>
			<view class="item-divider"></view>

			<view class="profile-item">
				<view class="item-label">客服热线：{{kfPhone}}</view>
				<view class="item-value">
					<button class="action-btn" @click="contactKf">联系客服</button>
				</view>
			</view>
			<view class="item-divider"></view>


			<view class="profile-item" @click="toInviteList">
				<view class="item-label">我的好友</view>
				<view class="item-value">
					<!-- <button class="action-btn" @click="shareToFriend" open-type="share">去邀请</button> -->
					<uni-icons type="right"></uni-icons>
				</view>
			</view>
			<view class="item-divider"></view>



			<!-- <view class="profile-item">
				<view class="item-label">剩余电话面试次数</view>
				<view class="item-value">
					<text>{{enableNum.remainCallNum}}次</text>
					<button class="action-btn" @click="toBuyNum(2)">去获取</button>
				</view>
			</view>
			<view class="item-divider"></view>
			
			<view class="profile-item">
				<view class="item-label">剩余查看微信次数</view>
				<view class="item-value">
					<text>{{enableNum.remainWxNum}}次</text>
					<button class="action-btn" @click="toBuyNum(1)">去获取</button>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {
					"birthday": "2022-04-04 00:00:00", //生日
					"createTime": "2025-03-04 10:37:02", //创建时间
					"dyOpenId": "", //抖音登录的id
					"hometown": "", //家乡
					"id": 1, //消息id
					"idCardNo": "",
					"loginTime": "2025-03-04 11:01:25",
					"nickname": "",
					"phone": "", //绑定登录的手机
					"realName": "", //真实姓名
					"sex": 0, //性别 0女1男
					"status": 1,
					"token": "",
					"weixin": "", //绑定微信号
					"wxOpenId": "",
					"wxUnionId": "" //微信登录的unionId
				},
				enableNum: {
					"remainCallNum": 0, //剩余电话面试次数
					"remainWxNum": 0, //剩余查看微信次数
				},
				kfPhone: '4008008830'
			}
		},
		onShow() {
			this.getUserInfo();
			this.getEnableNum();
		},
		onPullDownRefresh() {
			this.getUserInfo();
			this.getEnableNum();
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000)
		},
		methods: {
			toUserBind(type) {
				uni.navigateTo({
					url: '/pages/mine/userBind?type=' + type
				})
			},
			getUserInfo() {
				//获取用户信息
				this.$Request.postFormHost(this.$Api.getUserInfo).then(res => {
					if (res.status == 0) {
						this.userInfo = res.data;
					}
				})
			},
			getEnableNum() {
				//获取剩余次数
				this.$Request.postFormHost(this.$Api.getEnableNum).then(res => {
					if (res.status == 0) {
						this.enableNum = res.data;
					}
				})
			},
			toBuyNum(type) {
				uni.navigateTo({
					url: "/pages/mine/buyNum?type=" + type
				});
			},
			toEditResume() {
				uni.navigateTo({
					url: "/pages/service/completeResume"
				});
			},
			tocertVerify() {
				uni.navigateTo({
					url: "/pages/service/certVerify"
				});
			},
			toWithdraw() {
				uni.navigateTo({
					url: "/pages/mine/withdraw"
				});
			},
			contactKf() {
				uni.makePhoneCall({
					phoneNumber: this.kfPhone
				});
			},
			toInviteList() {
				uni.navigateTo({
					url: "/pages/mine/inviteList?inviteCode="+this.userInfo.inviteCode
				});
			},
		}
	}
</script>

<style>
	.profile-container {
		display: flex;
		flex-direction: column;
		align-items: center;
		height: 100%;
		background: linear-gradient(to bottom, #e73c3c10, #e73c3ca0);
		font-size: 28rpx;
		color: #333333;
	}

	.header-space {
		margin-top: 80rpx;
	}

	.profile-card {
		width: 90vw;
		border-radius: 16rpx;
		background-color: #ffffff;
		box-shadow: 0 4rpx 12rpx rgba(70, 130, 180, 0.15);
		border: 1rpx solid #e1eeff;
		padding: 20rpx 0;
		margin-bottom: 30rpx;
	}

	.profile-item {
		width: 100%;
		height: 110rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.item-label {
		font-weight: 500;
		color: #444444;
	}

	.item-value {
		display: flex;
		flex-direction: row;
		align-items: center;
		color: #666666;
	}

	.action-btn {
		margin-left: 20rpx;
		font-size: 24rpx;
		padding: 6rpx 20rpx;
		background-color: #e73c3c;
		color: #ffffff;
		border-radius: 8rpx;
		border: none;
	}

	.item-divider {
		width: 90%;
		height: 1rpx;
		background-color: #e1eeff;
		margin: 0 auto;
	}
</style>